<template>
	<view class="page-index" >
		<view v-if="info!=''">
			<view class="introduce-box">
				<view class="introduce-item1">
					<view class="left">
						<view class="name">
							{{info.name}}
						</view>
						<view class="value">
							{{info.scale}} · {{info.nature_id}}
						</view>
					</view>
					<image :src="info.logo" mode=""></image>
				</view>
				<view class="certification-box" v-if="info.certification">
					<view class="certification">
						<image src="/static/index/certification.png" mode=""></image>
						<view>
							雇主认证
						</view>
					</view>
				</view>
				<view class="welfare-box">
					<view class="welfare" v-for="(item,index) in welfare" :key="index">
						{{item}}
					</view>
				</view>
			</view>
			<view class="tabs-box">
				<view :class="tabsIndex==index?'tabs':'no'" v-for="(item,index) in tabs" :key="index"
					@click="tabsChange(index)">
					{{item.title}}
				</view>
			</view>
			<view class="tabs-item1" v-if="tabsIndex==0">
				<view class="title">
					公司简介
				</view>
				<text decode="true" class="decode">
					{{info.txt}}
				</text>
				<view class="address">
					<view class="title">
						需求地点
					</view>
					<view class="address-box">
						<image src="/static/index/location.png" ></image>
						<view>
							{{info.address}}
						</view>
					</view>
					<view class="lookMap" @click="location()">
						<view>
							查看地图
						</view>
						<image src="/static/index/right.png"></image>
					</view>
				</view>
			</view>
			<Work :workList='workList' :total="total" v-else/>
		</view>
		<view class="empty" v-if="code==0">
			<empty :text='text'></empty>
			<view class="back" @click="back()">
				返回
			</view>
		</view>
	</view>
</template>

<script>
	import * as index from '@/api/index.js'
	import Work from '@/components/home/work/index.vue'
	import empty from '@/components/empty/index.vue'
	export default {
		components: {
			Work,
			empty
		},
		onLoad(params) {
			this.getCompanyInfo(params.member_id)
			// this.getPosotionList(params.member_id)
		},
		data() {
			return {
				total:-1,
				info: '', //雇主详情
				tabs: [{
						title: '公司信息'
					},
					{
						title: '在招需求'
					}
				],
				tabsIndex: 0, //tabs选项
				form: {
					page: 1,
					pages: '99999',
					neqId: '',
					select_name: '',
					member_id: '',
					drving_id: '',
					age_id: '',
					welfare_id: '',
					salary_id: '',
					position_id2: '',
					position_id: '',
					areas_pid: '',
					areas_id: '',
					secondary: '',
					is_index: '',
				},//在招需求参数
				workList:[],//在招需求列表
				code:1,
				text:''
				
			}
		},
		methods: {
			//公司信息详情
			getCompanyInfo(member_id) {
				index.getCompanyInfo({
					member_id: member_id
				}).then(res => {
					if(res.data){
						this.info = res.data
						this.code = res.code
						this.getPosotionList(member_id)
					}
					else{
						this.text = res.msg
						this.code = 0
					}
					uni.setNavigationBarTitle({
						title: res.data.name
					});
				})
			},
			//切换标签
			tabsChange(index) {
				this.tabsIndex = index
			},
			//再招需求
			getPosotionList(member_id) {
				this.form.member_id = member_id
				index.getPosotionList(this.form).then(res => {
					this.workList.push(...res.data.data)
					this.total = res.data.total
				})
			},
			back(){
				this.$tools.back(1)
			},
			//查看地图
			location(){
				uni.openLocation({
					latitude: parseFloat(this.info.latitude),
					longitude: parseFloat(this.info.longitude),
					success: function(res) {
						console.log(res);
					},
					fail: function(res) {
						console.log(res);
					},
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		background: #FFFFFF;
	}

	.page-index {
		height: 100%;
		// padding: 0 40rpx;
		background: #FFFFFF;

		.introduce-box {
			// margin: 0 -40rpx;
			padding: 40rpx 40rpx 104rpx;
			background: #32424C;

			.introduce-item1 {
				display: flex;
				justify-content: space-between;

				image {
					width: 120rpx;
					height: 120rpx;
				}

				.left {
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.name {
						font-size: 42rpx;
						font-weight: 500;
						color: #CDCDCD;
					}

					.value {
						font-size: 24rpx;
						font-weight: 400;
						color: #FFFFFF;
					}
				}
			}

			.certification-box {
				display: flex;
				margin-top: 21rpx;

				.certification {
					display: flex;
					align-items: center;
					padding: 5rpx 13rpx;
					font-size: 20rpx;
					font-weight: 400;
					color: #C1FF00;
					border-radius: 10rpx;
					border: 1rpx solid #C1FF00;

					image {
						width: 20rpx;
						height: 24rpx;
					}
				}
			}

			.welfare-box {
				margin-top: 67rpx;
				display: flex;
				flex-wrap: wrap;

				.welfare {
					padding: 11rpx 20rpx;
					background: #405766;
					border-radius: 28rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #FFFFFF;
				}
			}

		}

		// .radio-box{

		// }
		.tabs-box {
			border-radius: 28rpx 28rpx 0 0;
			// height: 40rpx;
			margin-top: -40rpx;
			background: #FFFFFF;
			padding: 40rpx;
			display: flex;

			.tabs {
				margin-right: 73rpx;
				padding: 13rpx 0;
				border-bottom: 8rpx solid #FF6600;
				font-size: 32rpx;
				font-weight: 700;
				color: #333333;
				border-radius: 4rpx;
			}

			.no {
				margin-right: 73rpx;
				padding: 13rpx 0;
				border-bottom: 8rpx solid #ffffff;
				font-size: 32rpx;
				font-weight: 400;
				color: #666666;
			}
		}

		.tabs-item1 {
			padding: 40rpx;
			background: #ffffff;
			.title {
				font-size: 36rpx;
				font-weight: 700;
				color: #333333;
				margin-bottom: 45rpx;
			}

			.decode {
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
			}

			.address {
				margin-top: 52rpx;
				background: #ffffff;

				.title {
					font-size: 36rpx;
					font-weight: 700;
					color: #333333;
					margin-bottom: 45rpx;
				}

				.address-box {
					margin-top: 38rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #555555;
					display: flex;
					align-items: center;

					image {
						width: 33rpx;
						height: 40rpx;
						margin-right: 32rpx;
					}
				}

				.lookMap {
					margin-top: 21rpx;
					display: flex;
					align-items: center;
					font-size: 28rpx;
					font-weight: 400;
					color: #FF7700;

					image {
						margin-left: 8rpx;
						width: 13rpx;
						height: 22rpx;
					}
				}
			}
		}
		.empty{
			display: flex;
			flex-direction: column;
			align-items: center;
			.back{
				margin-top: 36rpx;
				width: 200rpx;
				text-align: center; 
				padding: 16rpx 32rpx;
				border: 1rpx solid #999999;
				color: #999999;
				border-radius: 16rpx;
			}
		}
	}
</style>
